﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EyFramework.Sys.Entity;
using EyFramework.Task.Entity;
using EyFramework.Task.Excutor;
using Quartz;

namespace EyFramework.Task.Jobs
{
    /// <summary>
    /// 定义调度器的JOB
    /// </summary>
    public class XseyJob : IJob
    {
        public System.Threading.Tasks.Task Execute(IJobExecutionContext context)
        {
            return System.Threading.Tasks.Task.Run(() =>
            {
                JobDataMap dataMap = context.MergedJobDataMap;
                QrtzCsTask taskInfo = (QrtzCsTask)dataMap.Get(TaskConstants.TASK_JOBDATAMAP_KEY);
                //根据不同的任务类型执行，不同的执行器
                IJobExecutor executor = TaskConstants.CreateExecutor(taskInfo.TASK_TYPE);
                ReturnData returnData = executor.Execute(taskInfo);
                Console.WriteLine($"触发时间：{context.ScheduledFireTimeUtc?.LocalDateTime},下次触发时间：{context.NextFireTimeUtc?.LocalDateTime}");
            });
        }
    }
}